package com.Sdebruijn.curriculumvitae.util;

import java.util.ArrayList;

import android.support.v4.app.Fragment;
import android.view.View;

public class ArrayUtils {

	/**
	 * Checks if a View needle is in array haystack
	 * 
	 * @param haystack
	 *            Array of views to iterate
	 * @param needle
	 *            view to search for in haystack
	 * @return boolean true when needle is found in haystack
	 */
	public static boolean containsView(View[] haystack, View needle) {
		for (View c : haystack) {
			if (c.equals(needle)) {
				return true;
			}
		}
		return false;
	}

	/**
	 * Check if a List<T> contains any Class T
	 * 
	 * @param haystack
	 *            List<T> to be searched through
	 * @param needle
	 *            Class<T> to be searched
	 * @return
	 */
	public static boolean contains(ArrayList<Fragment> haystack, Class<?> needle) {
		for (Object c : haystack) {
			if (c.equals(needle)) {
				return true;
			}
		}
		return false;
	}

}
